<?php
namespace app\admin\model;

use think\Db;
use think\Model;
                    

class ListContent extends Model
{

    public function getAll($where){
                    
        $rs = ListContent::where($where)

            ->order('list_sort','desc')

            ->paginate(10);
                    
        return $rs;

    }

    public function getIndexList($where){

        $rs = ListContent::where($where)

            ->order('index_sort desc')

            ->select();

        return $rs;
    }

    public function getAllPage($where=''){

        $rs = ListContent::where($where)

            ->order('list_sort','desc')

            ->paginate(10);

        return $rs;

    }

    public function getOne($where){
                    
        $rs = ListContent::alias('co')

            ->join('app_list_vedio vo','vo.lid = co.id','LEFT')

            ->field('co.*,vo.vedio_link as vo_vedio,vo.vedio_image as vo_image,vo.photo as vo_photo')

            ->where($where)
                    
        ->find();
                    
        return $rs;
                    
    }
                    
    public function add($data){
                    
        $rs = ListContent::data($data)
                    
        ->save();
                    
        return $rs;
                    
    }
                    
    public function edit($where,$data){
                    
        $rs = ListContent::where($where)
                    
        ->update($data);
                    
        return $rs;
                    
    }
                    
    public function del($where){
                    
        $rs = ListContent::where($where)
                    
        ->delete();
                    
        return $rs;
                    
    }

    public function totalNum(){
        $rs = ListContent::where('status',1)
            ->count('id');
        return $rs;
    }

    public function totalNumWhere($where){
        $rs = ListContent::where($where)
            ->count('id');
        return $rs;
    }
                    
}
                    
